<template>
	<view class="wrap">
		<Search @search-data="handleSearchData" v-show="false" />
		<view class="navProgramm">
			<u-subsection :list="tabList" :current="current" @change="sectionChange"></u-subsection>
		</view>
		<scroll-view class="scroll-list" scroll-y="true">
			<view v-show="this.showList1">
				<u-card class="task-list-item" :show-head="false" :border="true" padding="20" margin="20rpx"
					:head-border-bottom="false" v-for="(item,index) in comitList" :key="item.id">
					<view slot="body">
						<u-row gutter="16">
							<u-col span="12">
								<view class="apply-text"><text>{{item.wh_declare_num}}</text></view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>关联位置：</span>{{item.eq_name}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>事件类型：</span>{{item.ft_type_desc}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>申报时间：</span>{{item.wh_declare_time}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>申报人：</span>{{item.declare_person_name}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>是否响应：</span>
									<template v-if="item.response_status==1">
										是
									</template>
									<template v-if="item.response_status!=1">
										否
									</template>
								</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>是否验收：</span>
									<template v-if="item.wh_repair_status==9">
										是
									</template>
									<template v-if="item.wh_repair_status!=9">
										否
									</template>
								</view>
							</u-col>
						</u-row>
					</view>
					<view class="apply-list-foot" slot="foot" style="text-align: right;">
						<span @click="navTo(item.id)" style="margin-right: 10px;">申报查看</span>
						<template v-if="item.response_status==0 && item.wh_repair_status==6">
							<span @click="navToBJ(item.id)" style="margin-right: 10px;">编辑</span>
						</template>
						<template v-if="item.wh_repair_status==6 && item.is_edit==1">
							<span @click="navToCheck(item.id)" style="margin-right: 10px;">验收</span>
						</template>
						<template v-if="item.is_edit==1">
							<span @click="navToGd(item.id)" style="margin-right: 10px;">工单查看</span>
						</template>
					</view>
				</u-card>
				<u-divider>已经到底了</u-divider>
			</view>
			<view v-show="this.showList2">
				<u-card class="task-list-item" :show-head="false" :border="true" padding="20" margin="20rpx"
					:head-border-bottom="false" v-for="(item,index) in NotList" :key="item.id">
					<view slot="body">
						<u-row gutter="16">
							<u-col span="12">
								<view class="apply-text"><text>{{item.wh_repair_num}}</text></view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>关联位置：</span>{{item.eq_name}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>事件类型：</span>{{item.ft_fault_type}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>申报时间：</span>{{item.wh_declare_time}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>申报人：</span>{{item.declare_person_name}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>是否响应：</span>
									<template v-if="item.response_status==1">
										是
									</template>
									<template v-if="item.response_status!=1">
										否
									</template>
								</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>是否验收：</span>
									<template v-if="item.wh_repair_status==9">
										是
									</template>
									<template v-if="item.wh_repair_status!=9">
										否
									</template>
								</view>
							</u-col>
						</u-row>
					</view>
					<view class="apply-list-foot" slot="foot" style="text-align: right;">
						<template v-if="item.response_status==1 && item.wh_repair_status==9">
							<span @click="navTo(item.id)" style="margin-right: 10px;">申报查看</span>
							<span @click="navToGd(item.id)" style="margin-right: 10px;">工单查看</span>
						</template>
						<template v-if="item.response_status==1 && item.wh_repair_status==6 &&item.is_edit==1">
							<span @click="navTo(item.id)" style="margin-right: 10px;">申报查看</span>
							<span @click="navToGd(item.id)" style="margin-right: 10px;">工单查看</span>
						</template>
						<template v-if="item.response_status==1 && item.wh_repair_status==6 &&item.is_edit==0">
							<span @click="navTo(item.id)" style="margin-right: 10px;">申报查看</span>
							<span @click="navToEdit(item.id)" style="margin-right: 10px;">编辑</span>
						</template>
						<template v-if="item.response_status==0 && item.wh_repair_status==6">
							<span @click="navTo(item.id)" style="margin-right: 10px;">申报查看</span>
							<span @click="navToResponse(item.id)" style="margin-right: 10px;">响应</span>
						</template>
					</view>
				</u-card>
				<u-divider>已经到底了</u-divider>
			</view>
			<view v-show="this.showList3">
				<u-card class="task-list-item" :show-head="false" :border="true" padding="20" margin="20rpx"
					:head-border-bottom="false" v-for="(item,index) in FinishList" :key="item.id">
					<view slot="body">
						<u-row gutter="16">
							<u-col span="12">
								<view class="apply-text"><text>{{item.wh_repair_num}}</text></view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>关联位置：</span>{{item.eq_name}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>事件类型：</span>{{item.ft_fault_type}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>申报时间：</span>{{item.wh_declare_time}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>申报人：</span>{{item.declare_person_name}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>是否响应：</span>
									<template v-if="item.response_status==1">
										是
									</template>
									<template v-if="item.response_status!=1">
										否
									</template>
								</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>是否验收：</span>
									<template v-if="item.wh_repair_status==9">
										是
									</template>
									<template v-if="item.wh_repair_status!=9">
										否
									</template>
								</view>
							</u-col>
						</u-row>
					</view>
					<view class="apply-list-foot" slot="foot" style="text-align: right;">
						<span @click="navTo(item.id)" style="margin-right: 10px;">申报查看</span>
						<span @click="navToGd(item.id)">工单查看</span>
					</view>
				</u-card>
				<u-divider>已经到底了</u-divider>
			</view>
		</scroll-view>
	</view>
</template>
<script>
	import Search from '@/components/headsearch/searchEventOrder.vue'

	export default {
		components: {
			Search
		},
		data() {
			return {
				//厂站
				searchData: '', // 用于保存接收到的数据
				//查询时间
				searchTime: '',
				tabList: [{
						name: '已申报'
					},
					{
						name: '未完成'
					},
					{
						name: '已完成'
					}
				],
				current: 0,
				showList1: true,
				showList2: false,
				showList3: false,
				//未完成列表
				comitList: [],
				NotList: [],
				FinishList: []
			}
		},
		created() {},
		onReady() {

		},
		methods: {
			//查看申报
			navTo(id) {
				console.log("申")
				uni.navigateTo({
					url: "/pages/sys/eventwororder/seeclaration/seeclaration?id=" + id
				});
			},
			//查看工单
			navToGd(id) {
				uni.navigateTo({
					url: "/pages/sys/eventwororder/seeorder/seeorder?id=" + id
				});
			},
			//查看工单
			navToBJ(id) {
				uni.navigateTo({
					url: "/pages/sys/eventwororder/editdeclaration/editdeclaration?id=" + id
				});
			},
			//编辑
			navToEdit(id) {
				uni.navigateTo({
					url: "/pages/sys/eventwororder/editorder/editorder?id=" + id
				});
			},
			//响应
			navToResponse(id) {
				console.log("响应")
				uni.navigateTo({
					url: "/pages/sys/eventwororder/responseclaration/responseclaration?id=" + id
				});
			},
			//验收
			navToCheck(id) {
				uni.navigateTo({
					url: "/pages/sys/eventwororder/responseorder/seeorder?id=" + id
				});
			},
			//分段器回调
			sectionChange(index) {
				this.current = index;
				console.log("ceshi.", index)
				if (this.current == 0) {
					this.showList1 = true
					this.showList2 = false
					this.showList3 = false
				} else if (this.current == 1) {
					this.showList1 = false
					this.showList2 = true
					this.showList3 = false
				} else {
					this.showList1 = false
					this.showList2 = false
					this.showList3 = true
				}
				console.log(this.current)
			},
			handleSearchData(data, times) {
				this.searchData = data; // 接收到子组件传递过来的数据
				this.times = times; // 接收到子组件传递过来的数据
				this.searchNotdo()
				this.searchFinished()
				this.searchCommit()
			},
			//已提交列表
			searchCommit() {
				console.log(this.searchData, this.times, "已申报列表")
				this.$u.api.searchNotdo({
					"algorithmProcessId": "getCommitOrder",
					"param": {
						"data": {
							// wh_organ_uuid: this.searchData,//厂站id
							wh_organ_uuid: uni.getStorageSync('navId'),
							user_uuid: uni.getStorageSync('uuid'), //用户id
							pageNumber: "1", //页数
							pageSize: "20", //页面数据大小
							start_time: this.times, //时间
						}
					}
				}).then(res => {
					this.comitList = res.data.data.result.list ? res.data.data.result.list : []
				}).catch(error => {
					this.$u.toast('查询异常');
					console.error(error);
				});
			},
			//未完成列表
			searchNotdo() {
				console.log(this.searchData, this.times, "未完成列表")
				this.$u.api.searchNotdo({
					"algorithmProcessId": "noFinishOrder",
					"param": {
						"data": {
							// wh_organ_uuid: this.searchData,//厂站id
							wh_organ_uuid: uni.getStorageSync('navId'),
							user_uuid: uni.getStorageSync('uuid'), //用户id
							pageNumber: "1", //页数
							pageSize: "20", //页面数据大小
							start_time: this.times, //时间
						}
					}
				}).then(res => {
					this.NotList = res.data.data.result.list ? res.data.data.result.list : []
				}).catch(error => {
					this.$u.toast('查询异常');
					console.error(error);
				});
			},
			//完成列表
			searchFinished() {
				console.log(this.searchData, this.times, "完成列表")
				this.$u.api.searchNotdo({
					"algorithmProcessId": "getFinishOrder",
					"param": {
						"data": {
							// wh_organ_uuid: this.searchData,//厂站id
							wh_organ_uuid: uni.getStorageSync('navId'),
							user_uuid: uni.getStorageSync('uuid'), //用户id
							pageNumber: "1", //页数
							pageSize: "20", //页面数据大小
							start_time: this.times, //时间
							wh_repair_status: "9" //验收完成
						}
					}
				}).then(res => {
					this.FinishList = res.data.data.result.list ? res.data.data.result.list : []
				}).catch(error => {
					this.$u.toast('查询异常');
					console.error(error);
				});
			}
		},
	};
</script>
<style lang="scss" scoped>
	@import '../style/common.scss';

	.scroll-list {
		background-color: #fff;
	}

	.task-list-item {
		box-shadow:
			-4rpx -4rpx 6rpx rgba(0, 0, 0, 0.1),
			4rpx -4rpx 6rpx rgba(0, 0, 0, 0.1),
			-4rpx 4rpx 6rpx rgba(0, 0, 0, 0.1),
			4rpx 4rpx 6rpx rgba(0, 0, 0, 0.1) !important;
	}


	.uni-title {
		font-size: 30rpx;
		color: #333333;
		padding: 20rpx;
		background: #fff;
		border-top: 2rpx solid #ededed;
		margin-top: 20rpx;
	}

	.uni-media-list {
		padding: 15px 15px;
	}

	.uni-media-list-body {
		height: 42px;
		padding-left: 20rpx;
	}

	.uni-media-list-text-top {
		height: 40rpx;
		overflow: hidden;
		width: 100%;
		line-height: 40rpx;
		font-size: 32rpx;
		display: flex;
		justify-content: space-between;
	}

	.uni-media-list-text-bottom {
		width: 100%;
		line-height: 24rpx;
		font-size: 26rpx;
		color: #666666;

		span {
			margin-right: 10rpx;
		}
	}


	.apply-text {
		font-size: 28rpx;
		color: #333333;
		height: 50rpx;

		span {
			color: #999999;
		}
	}


	.apply-list-foot {
		font-size: 28rpx;
	}


	.searchButton {
		height: 50rpx;
	}

	.selectCondition {

		.search {
			display: inline-block;
			width: 300rpx;

		}

		.selectItem {
			display: contents;
		}

	}

	.wrap .navProgramm {
		white-space: nowrap;

		.item {
			width: 50%;
			height: 220rpx;
			display: inline-block;
			margin-right: 10rpx;
		}
	}

	.head-text {
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
		padding: 30rpx 0;
	}
</style>